<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
   <link rel="stylesheet" href="__PUBLIC__/Css/Admin/common.css">
   <link rel="stylesheet" href="__PUBLIC__/Css/Admin/main.css">
   <script type="text/javascript" src="__PUBLIC__/Js/Admin/jquery.min.js"></script>
   <title>修改密保问题</title>
   
   <script type="text/javascript">
       $(function(){
    	   // 提交前check
    	   checkBeforeSubmit();
       });
       
       // 提交前check
       function checkBeforeSubmit(){
    	   $("#save_button").click(function(){
    		   var questionId = $("input[name='id']").val();
    		   // 问题
    		   var question = $("input[name='question']").val();
    		   
    		   // 输入check 
    		   if($.trim(question) == ""){
    			   alert("请输入问题！");
    			   return false;
    		   }
    		   if($.trim(questionId) == ""){
    			   $.ajax({
    	    			  url:"__URL__/hasExisted",
    	    			  type:"POST",
    					  async: false,
    					  data: "question=" + $.trim(question),
    					  dataType: "json",
    					  success:function(data) {
    						  	if(data.status == 200){
    	  							//已经存在
    	  							alert(data.message);
    	  							$(this).focus();
    	  						} else {
    	  							$("#question_form").submit(); 
    	  						}
    					  },
    					  error:function(){
    					    	
    					  }
    	    		   });
    		   } else {
    			   $.ajax({
 	    			  url:"__URL__/hasExisted",
 	    			  type:"POST",
 					  async: false,
 					  data: "id=" + $.trim(questionId) + "&question=" + $.trim(question) ,
 					  dataType: "json",
 					  success:function(data) {
 						  	if(data.status == 200){
 	  							//已经存在
 	  							alert(data.message);
 	  							$(this).focus();
 	  						} else {
 	  							$("#question_form").submit(); 
 	  						}
 					  },
 					  error:function(){
 					    	
 					  }
 	    		   }); 
    		   }
    	   });
       }
   </script>
</head>
<body>
<div id="forms" class="mt10">
       <div class="box">
          <div class="box_border">
            <div class="box_top">
            	<b class="pl15">{$title}</b>
            	<a class="ext_btn" onclick="location.href='javascript:history.go(-1)'" style="float:right;margin-right:10px;margin-top:5px;">返回</a>
            </div>
            <div class="box_center">
              <form action="{:U('Other/saveSecurityQuestion')}" class="jqtransform" id="question_form" method="post" enctype="multipart/form-data">
                <input type="hidden" name="id" value="{$question.id}">
               <table class="form_table pt15 pb15" style="width:100%">
                <tr>
                  <td class="td_right">问题：</td>
                  <td class=""> 
                    <input type="text" name="question" class="input-text lh30" size="40" value="{$question.question}">
                  </td>
                </tr>
                 <tr>
                   <td class="td_right">&nbsp;</td>
                   <td class="">
                     <input type="button" name="save_button" id="save_button" class="btn btn82 btn_save2" value="保存"> 
                    <input type="reset" name="reset_button" class="btn btn82 btn_res" value="重置">
                   </td>
                 </tr>
               </table>
               </form>
            </div>
          </div>
        </div>
     </div>
</body>
</html>